<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <meta name="renderer" content="webkit|ie-comp|ie-stand">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport"
        content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
  <meta http-equiv="Cache-Control" content="no-siteapp"/>
  <LINK rel="Bookmark" href="yi.ico">
  <LINK rel="Shortcut Icon" href="yi.ico"/>
  <!--[if lt IE 9]>
  <script type="text/javascript" src="libs/html5.js"></script>
  <script type="text/javascript" src="libs/respond.min.js"></script>
  <script type="text/javascript" src="libs/PIE_IE678.js"></script>
  <![endif]-->
  <link rel="stylesheet" type="text/css" href="libs/h-ui/css/H-ui.min.css"/>
  <link rel="stylesheet" type="text/css" href="libs/h-ui.admin/css/H-ui.admin.css"/>
  <link rel="stylesheet" type="text/css" href="libs/Hui-iconfont/1.0.7/iconfont.css"/>
  <link rel="stylesheet" type="text/css" href="libs/icheck/icheck.css"/>
  <link rel="stylesheet" type="text/css" href="libs/h-ui.admin/skin/default/skin.css" id="skin"/>
  <link rel="stylesheet" type="text/css" href="libs/h-ui.admin/css/H-ui.login.css"/>
  <!--[if IE 6]>
  <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js"></script>
  <script>DD_belatedPNG.fix('*');</script>
  <![endif]-->
  <title>首页-UI自动化测试平台</title>
</head>
<body>
<header class="navbar-wrapper">
  <div class="navbar navbar-fixed-top">
    <div class="container-fluid cl"><a class="logo navbar-logo f-l mr-10 hidden-xs" href=""><span id="siteName"></span></a>
      <a class="logo navbar-logo-m f-l mr-10 visible-xs" href="">DCITS</a> <span
          class="logo navbar-slogan f-l mr-10 hidden-xs" id="version"></span> <a aria-hidden="false"
                                                                                 class="nav-toggle Hui-iconfont visible-xs"
                                                                                 href="javascript:;">&#xe667;</a>
      <nav class="nav navbar-nav">
        <ul class="cl">
          <li class="dropDown dropDown_hover">
            <a href="javascript:;" class="dropDown_A" id="system-type-name">切换系统<i class="Hui-iconfont">&#xe6d5;</i></a>
            <ul class="dropDown-menu menu radius box-shadow">
            </ul>
          </li>
        </ul>
      </nav>
      <nav id="Hui-userbar" class="nav navbar-nav navbar-userbar hidden-xs">
        <ul class="cl">
          <li id="role_name"></li>
          <li class="dropDown dropDown_hover"><a href="#" class="dropDown_A" id="real_name"><i class="Hui-iconfont">&#xe6d5;</i></a>
            <ul class="dropDown-menu menu radius box-shadow">
              <li class="redirect-to-page"><a href="javascript:">修改密码</a></li>
              <li class="redirect-to-page"><a href="javascript:;">切换账户</a></li>
              <li><a href="javascript:;" onclick="to_logout()">退出</a></li>
            </ul>
          </li>
          <li id="Hui-msg"><a _href="#" data-title="我的邮件" href="javascript:void(0)" title="消息"
                              class="openIframeNew"><span class="badge badge-danger noReadMailNum"></span><i
              class="Hui-iconfont" style="font-size:18px">&#xe68a;</i></a></li>
          <li id="Hui-skin" class="dropDown right dropDown_hover"><a href="javascript:;" class="dropDown_A"
                                                                     title="换肤"><i class="Hui-iconfont"
                                                                                   style="font-size:18px">&#xe62a;</i></a>
            <ul class="dropDown-menu menu radius box-shadow">
              <li><a href="javascript:;" data-val="default" title="默认（黑色）">默认（黑色）</a></li>
              <li><a href="javascript:;" data-val="blue" title="蓝色">蓝色</a></li>
              <li><a href="javascript:;" data-val="green" title="绿色">绿色</a></li>
              <li><a href="javascript:;" data-val="red" title="红色">红色</a></li>
              <li><a href="javascript:;" data-val="yellow" title="黄色">黄色</a></li>
              <li><a href="javascript:;" data-val="orange" title="绿色">橙色</a></li>
            </ul>
          </li>
        </ul>
      </nav>
    </div>
  </div>
</header>
<aside class="Hui-aside">
  <input runat="server" id="divScrollValue" type="hidden" value=""/>
  <div class="menu_dropdown bk_2" id="menu">
    <!-- 左侧菜单 -->
  </div>
</aside>
<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a>
</div>
<section class="Hui-article-box">
  <div id="Hui-tabNav" class="Hui-tabNav hidden-xs">
    <div class="Hui-tabNav-wp">
      <ul id="min_title_list" class="acrossTab cl">
        <li class="active"><span title="我的工作台" data-href="A_welcome.html">我的工作台</span><em></em></li>
      </ul>
    </div>
    <div class="Hui-tabNav-more btn-group"><a id="js-tabNav-prev" class="btn radius btn-default size-S"
                                              href="javascript:;"><i class="Hui-iconfont">&#xe6d4;</i></a><a
        id="js-tabNav-next" class="btn radius btn-default size-S" href="javascript:;"><i
        class="Hui-iconfont">&#xe6d7;</i></a></div>
  </div>
  <div id="iframe_box" class="Hui-article">
    <div class="show_iframe">
      <div style="display:none" class="loading"></div>
      <iframe scrolling="no" frameborder="0" src="" name="welcome"></iframe>
    </div>
  </div>
  <input type="hidden" id="user_id"/>
</section>

<div class="contextMenu" id="Huiadminmenu">
  <ul>
    <li id="closethis">关闭当前</li>
    <li id="closeall">关闭全部</li>
    <li id="closeother">关闭其他</li>
  </ul>
</div>
<div id="templates-page" style="display: none;"></div>
<div id="children-page" style="display: none;"></div>
<div id="menu-page" style="display: none;"></div>
<script type="text/javascript" src="libs/jquery/1.9.1/jquery.js"></script>
<script type="text/javascript" src="libs/layer/2.1/layer.js"></script>
<script type="text/javascript" src="libs/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="libs/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="libs/handlebars.js"></script>
<script type="text/javascript" src="libs/jquery.contextmenu/jquery.contextmenu.r2.js"></script>
<script type="text/javascript" src="js/globalUtils.js"></script>
<script type="text/javascript" src="js/constant.js"></script>
<script type="text/javascript">
  var templates;
  var htmls;
  var explanationMarks;
  var menuJson;
  var token = getCookie('tdp_token');

  var backUrl;
  $(document).ready(function () {
    var sso_token = GetQueryString("sso_token");
    backUrl = GetQueryString("backUrl");
    if (GLOBAL_UTILS.stringUtils.isNotBlank(sso_token)) {
      token = sso_token;
      setCookie('tdp_token', sso_token);
    }

    //初始化加载菜单
    loadMenuTemplate();

    $('iframe').attr("src", "welcome.html");

    /***************************/

    $(".openIframeNew").on("click", function () {
      Hui_admin_tab(this);
    });

    /*******************初始化子iFrame中的模板和远程子页面html代码***************************/
    //模板id
    templates = initHandlebarsTemplate();


    //页面名
    htmls = loadChildrenHtml(["interfaceParameter-viewTree",
      "messageScene-test",
      "messageScene-validateFullJson",
      "messageScene-validateKeyword",
      "role-power",
      "viewWindow"]);
    /*****************************************************/

    $.getJSON("./js/json/explanationMarks.json", function (json) {
      explanationMarks = json;
    });

    //获取配置项
    GLOBAL_UTILS.ajaxUtils.ajaxGet(REQUEST_URL.CONFIG.getDict, function (data) {
      DICT_CONFIG = data.data;
    });
  });

  /*************预先编译子iframe中的模板***************/
  function initHandlebarsTemplate() {
    var loadingIndex = layer.msg('正在初始化系统...', {icon: 16, shade: 0.45, time: 999999999});
    var templates = {};
    $("#templates-page").load("./resource/template/customTemplate.htm", function () {
      $("#templates-page > script").each(function (i, n) {
        templates[$(n).attr('id')] = Handlebars.compile($(n).html());
      });
      layer.close(loadingIndex);
    });
    return templates;
  }

  /********************加载菜单***************************/
  function loadMenuTemplate() {
    $.get('./mock/getUserMenus.json', function (data) {
      if (data.returnCode == 0) {
        menuJson = data.data;
        var systemSwitchDom = $('#system-type-name').siblings('ul');
        var defaultTypeKey = null;
        $.each(menuJson, function (systemKey, content) {
          defaultTypeKey == null && (defaultTypeKey = systemKey);
          systemSwitchDom.append('<li><a system-type="' + systemKey + '" href="javascript:void(0)" class="switch-system"><i class="Hui-iconfont ' + content.icon + '"></i>' + content.name + '</a></li>');
        });

        $("#menu-page").load("./resource/template/menuTemplate.htm", function () {
          templates['menu-template'] = Handlebars.compile($("#menu-page > script").html());
          loadMenu(getCookie('menuType') == null ? defaultTypeKey : getCookie('menuType'), true, defaultTypeKey);
          $(".switch-system").click(function () {
            var name = loadMenu($(this).attr('system-type'));
            name && (layer.msg('已切换至系统：' + name, {time: 2000}));
          });
        })
      } else {
        layer.alert('获取菜单信息失败:' + (data.msg || '未知原因'), {icon: 5});
      }
    });
  }

  function loadMenu(menuType, init, defaultTypeKey) {
    if (menuType == null) {
      menuType = "interface";
    }
    if (menuType == getCookie('menuType') && !init) {
      return null;
    }
    if (menuJson[menuType] == null) {
      menuType = defaultTypeKey;
    }
    $("#menu").html(templates['menu-template'](menuJson[menuType]['menu']));
    //重新初始化菜单效果
    $.Huifold(".menu_dropdown dl dt", ".menu_dropdown dl dd", "fast", 3, "click");
    //第一个菜单为打开状态
    $("#menu dt:eq(0)").click();
    //如果切换的是其他的系统菜单，则关闭全部的Tab选项卡
    //$("#min_title_list li i").trigger("click");
    setCookie("menuType", menuType);
    $("#system-type-name").html(menuJson[menuType]['name'] + '<i class="Hui-iconfont">&#xe6d5;</i>');
    return menuJson[menuType]['name'];
  }

  /*****预先加载子页面代码到内存*******/
  function loadChildrenHtml(options) {
    if (options == null || typeof options != 'object') {
      return false;
    }
    var htmls = {};
    $.each(options, function (i, n) {
      $("#children-page").append('<div id="' + n + '"></div>');
      $("#" + n).load("./resource/template/" + n + ".htm", function () {
        htmls[n] = $("#" + n).html();
        $("#" + n).html('');
      });
    });
    return htmls;
  }

  /***********手动点击logout会清除登录信息cookie*********/
  function to_logout() {
    clearCookie("tdp_token");
    if (GLOBAL_UTILS.stringUtils.isNotBlank(backUrl)) {
      window.location.href = 'http://' + backUrl;
    } else {
      window.location.href = 'login.html';
    }
  }


  /*****************************Handlebars预定义helper***********************************/
  /**null转换空字符串**/
  Handlebars.registerHelper('inputValue', function (value, defaultValue) {
    if (value == null || value.length == 0) {
      value = defaultValue;
    }

    return value;
  });

  /**结果标签展示**/
  Handlebars.registerHelper('resultLabelView', function (status) {
    var color = "";
    var flag = "";
    if (status == "0") {
      color = "success";
      flag = "SUCCESS";
    } else if (status == "1") {
      color = "danger";
      flag = "FAIL";
    } else {
      color = "default";
      flag = "STOP";
    }

    return '<span class="label label-' + color + ' radius">' + flag + '</span>';
  });


  Handlebars.registerHelper('if_eq', function (v1, v2, opts) {
    if (v1 == v2)
      return opts.fn(this);
    else
      return opts.inverse(this);
  });


  Handlebars.registerHelper('validate_path', function (v1) {
    if (v1 && !isJSON('{' + v1 + '}')) {
      return v1 + ".";
    }

    return "";
  });

  /**
   * 获取地址栏参数
   * @param name
   * @returns
   */
  function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null)
      return decodeURIComponent(r[2]);
    return null;
  }

  /**
   * 判断是否为json格式字符串
   * @param str
   */
  function isJSON(str) {
    if (typeof str == 'string') {
      try {
        var obj = JSON.parse(str);
        if (typeof obj == 'object' && obj) {
          return true;
        } else {
          return false;
        }

      } catch (e) {
        console.log('error：' + str + '!!!' + e);
        return false;
      }
    }
    console.log('It is not a string!')
  }
</script>
</body>
</html>
